Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator manager commands for the Keymanager APIs #6261

Open
wants to merge 86 commits into
base: unstable
Choose a base branch
from

Conversation

chong-he
Copy link
Member

@chong-he chong-he commented Aug 15, 2024

Issue Addressed

Proposed Changes

Add commonds to lighthouse vm to support the Keymanager API to manage local keystores, i.e., list, import and delete

Additional Info

Building on top of @pahor167 PR: #5347

Some other modifications:

  • modify the import logging where only successful import will display the log (previously it will display the log once the HTTP API is called even though the import is not successful, e.g., incorrect password)
  • added logging for successful delete

@michaelsproul michaelsproul added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Sep 12, 2024
Copy link
Member Author

@chong-he chong-he left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review and help @macladson and @michaelsproul. I added some comments to some parts that I am not sure. The import command now supports importing keystore JSON files created using:

  • lighthouse vm create by using the command lighthouse vm import
  • staking-deposit-cli or ethstaker-deposit-cli using lighthouse vm import --standard-format

@macladson mentioned about supporting multiple validators with the standard format, I will look into this; in the mean time, this is ready for a re-review.

Thanks!

fee_recipient: None,
builder_boost_factor: None,
gas_limit: None,
builder_proposals: Some(false),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to let this to be Some(false) for the comparison to be equal. Not sure if this is ok?
The same goes for prefer_builder_proposals field

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is because of here.

We set it in the config directly as Some(get_flag) so in the case the flag is missing it will be set to Some(false).
Unless I'm missing something, I think this should probably just be a parse_optional like the other fields in the config.

Keystore::from_json_file(&validators_file_path).map_err(|e| format!("{e:?}"))?,
),
voting_keystore_password: password.ok_or_else(|| {
"The --password flag is required to supply the keystore password".to_string()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to put ok_or_else here to handle the None case (when --password flag) is not provided. We already have requires here, so not sure about this here, or under what condition will this manifest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we want to support both formats, we have to have password be an Option. Then since we want to build the ImportConfig before we know which format we are using, we are stuck with password being an Option.

The or_else should never trigger since the require will trigger before we even get here, but this pattern is fine as is imo. We have redundant patterns like this in plenty of places.

validator_manager/src/import_validator.rs Outdated Show resolved Hide resolved
fee_recipient: None,
builder_boost_factor: None,
gas_limit: None,
builder_proposals: Some(false),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is because of here.

We set it in the config directly as Some(get_flag) so in the case the flag is missing it will be set to Some(false).
Unless I'm missing something, I think this should probably just be a parse_optional like the other fields in the config.

@@ -80,14 +83,94 @@ pub fn cli_app() -> Command {
)
.display_order(0),
)
.arg(
Arg::new(PASSWORD)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the --password flag only valid when using --standard-format? If that's the case, we should add a .requires(STANDARD_FORMAT) to its cli definition. This is kind of circular but I think it should be fine. Without this, a user would be able to use the --password flag when using the Lighthouse format which would be silently ignored.

Keystore::from_json_file(&validators_file_path).map_err(|e| format!("{e:?}"))?,
),
voting_keystore_password: password.ok_or_else(|| {
"The --password flag is required to supply the keystore password".to_string()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we want to support both formats, we have to have password be an Option. Then since we want to build the ImportConfig before we know which format we are using, we are stuck with password being an Option.

The or_else should never trigger since the require will trigger before we even get here, but this pattern is fine as is imo. We have redundant patterns like this in plenty of places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review The code is ready for review v6.0.0 New major release for hierarchical state diffs val-client Relates to the validator client binary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants